package com.fr.cell.core;

import java.awt.Toolkit;
import java.io.Serializable;
import javax.swing.JTextField;
import javax.swing.text.AttributeSet;
import javax.swing.text.BadLocationException;
import javax.swing.text.PlainDocument;

public class EditTextField extends JTextField
  implements Serializable
{
  private int maxLength;

  public EditTextField()
  {
    this(10000);
  }

  public EditTextField(int paramInt)
  {
    this.maxLength = 24;
    this.maxLength = paramInt;
    setDocument(new TextDocument(this));
  }

  public int getMaxLength()
  {
    return this.maxLength;
  }

  public void setMaxLength(int paramInt)
  {
    this.maxLength = paramInt;
  }

  class TextDocument extends PlainDocument
  {
    private final EditTextField this$0;

    public TextDocument()
    {
      this.this$0 = paramEditTextField;
    }

    public void insertString(, String paramString, AttributeSet paramAttributeSet)
      throws BadLocationException
    {
      String str = getText(0, getLength());
      if ((str != null) && (str.length() > this.this$0.getMaxLength()))
      {
        Toolkit.getDefaultToolkit().beep();
        return;
      }
      super.insertString(paramInt, paramString, paramAttributeSet);
    }
  }
}